package com.wfcm.service.impl;

import com.wfcm.dao.WfCollageOrderDao;
import com.wfcm.entity.WfCollageOrderEntity;
import com.wfcm.service.WfCollageOrderService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

import com.wfcm.dao.WfCollageActivityDao;
import com.wfcm.entity.WfCollageActivityEntity;
import com.wfcm.service.WfCollageActivityService;



@Service("wfCollageActivityService")
public class WfCollageActivityServiceImpl implements WfCollageActivityService {
	@Autowired
	private WfCollageActivityDao wfCollageActivityDao;
	@Autowired
	private WfCollageOrderService collageOrderService;

	@Override
	public WfCollageActivityEntity queryObject(Integer id) {
		WfCollageActivityEntity activity = wfCollageActivityDao.queryObject(id);
		List<String> list = collageOrderService.queryHeadImgs(id);
		if (list.size() >= 5) {
			activity.setHeadImgs(list.subList(0, 5));
		}
		else if (list.size() > 0) {
			activity.setHeadImgs(list.subList(0, list.size()));
		}
		activity.setCount(list.size());
		return activity;
	}
	
	@Override
	public List<WfCollageActivityEntity> queryList(Map<String, Object> map){
		return wfCollageActivityDao.queryList(map);
	}

	@Override
	public List<WfCollageActivityEntity> queryByCourseId(Map<String, Object> map){
		return wfCollageActivityDao.queryByCourseId(map);
	}

	@Override
	public int queryTotal(Map<String, Object> map){
		return wfCollageActivityDao.queryTotal(map);
	}
	
	@Override
	public void save(WfCollageActivityEntity wfCollageActivity){
		wfCollageActivityDao.save(wfCollageActivity);
	}
	
	@Override
	public void update(WfCollageActivityEntity wfCollageActivity){
		wfCollageActivityDao.update(wfCollageActivity);
	}
	
	@Override
	public void delete(Integer id){
		wfCollageActivityDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Integer[] ids){
		wfCollageActivityDao.deleteBatch(ids);
	}

	@Override
	public List<WfCollageActivityEntity> queryAllActivity(String version) {
		return wfCollageActivityDao.queryAllActivity(version);
	}

}
